package DAO;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;

public class DatabaseHelper extends SQLiteOpenHelper {
	private static final String TAG = "EasyNotes";
	
	private static final String DATABASE_CREATE =
	        "create table notes (_id integer primary key autoincrement, "
	        + "title text not null," +
	        "date text not null, body text not null,_folder text not null);";
	
	private static final String DATABASE_PICTURE =
			"create table pictures (_id integer primary key, "
	                + "maghichu long not null, urlPic text not null);";
	
	private static final String DATABASE_PAINT =
			"create table paint (_id integer primary key, "
	                + "maghichu long not null, urlPaint text not null);";
	
	private static final String DATABASE_NAME = "EasyNotes";
	
	private static final int DATABASE_VERSION = 2;
	
    DatabaseHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {

        db.execSQL(DATABASE_CREATE);
        db.execSQL(DATABASE_PICTURE);
        db.execSQL(DATABASE_PAINT);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        Log.w(TAG, "Upgrading database from version " + oldVersion + " to "
                + newVersion + ", which will destroy all old data");
        db.execSQL("DROP TABLE IF EXISTS notes");
        db.execSQL("DROP TABLE IF EXISTS pictures");
        db.execSQL("DROP TABLE IF EXISTS paint");
        onCreate(db);
    }
}